/*************************************
 **   @author: 野狼上校               **
 **   @create: 2024-04-04 12:34      **
 **   @version: 1.0                  **
 *************************************/
/**  类别数据持久化 **/

import {defineStore} from "pinia";

export const categoryStore = defineStore("categoryStore",{
    state: () => {
        return {
            categories: [],
        }
    },
    actions: {
        /*可以使用同步/异步*/
        async setCategories(categories: Array){
            this.categories = categories;
        },
    },

    /*开启数据持久化存储*/
    persist: [{
        key: 'shangxiao_categories',
        storage: sessionStorage, // 默认：sessionStorage,可以有其它选项，如: localStorage
        //paths:['token','userInfo']
    }]
})